package cn.topevery.garden.dal.logic;

import cn.topevery.garden.dal.dao.ToiletsFileDao;
import cn.topevery.garden.entity.po.ToiletsFile;
import cn.topevery.garden.entity.query.ToiletsFileQuery;
import cn.topevery.garden.framework.base.BaseLogic;
import hw.topevery.framework.db.base.BaseEntityDao;
import hw.topevery.framework.db.entity.DataPager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 
 *
 * @author code-generate
 * @date 2021-08-31
 */
@Service
public class ToiletsFileLogic extends BaseLogic<ToiletsFile> {
    @Autowired
    ToiletsFileDao toiletsFileDao;

    @Override
    public BaseEntityDao<ToiletsFile, Integer> getDao() {
        return toiletsFileDao;
    }

    

    /**
     * 获取列表
     *
     * @param query
     */
    public DataPager<ToiletsFile> listPage(ToiletsFileQuery query) {
        return toiletsFileDao.listPage(query);
    }

    public List<ToiletsFile> getListByPid(Integer pid){
        return toiletsFileDao.getListByPid(pid);
    }

    /**
     * 根据自增id批量删除
     *
     * @param ids
     */
    public void deleteBatchById(String userId,Integer[] ids) {
        toiletsFileDao.delete(userId, ids);
    }

    /**
     * 根据自增id保存或者更新
     *
     * @param toiletsFileList 实体
     */
    public void saveOrUpdate(String userId, Integer pid, List<ToiletsFile> toiletsFileList){
        toiletsFileDao.deleteById(pid);
        for(ToiletsFile toiletsFile : toiletsFileList){
            toiletsFile.setMainId(pid);
            toiletsFileDao.saveOrUpdate(userId,toiletsFile);
        }
    }
}
